<template>
  <div>
    <el-carousel height="400px" style="margin-left: 300px;margin-right: 300px">
      <el-carousel-item v-for="item in images" :key="item" >
        <img :src="item" style="width: 100%"/>
      </el-carousel-item>
    </el-carousel>
    <div>
      <section class="container">
        <header class="comm-title">
          <h2 class="tac">
            <span class="c-333">热门视频</span>
          </h2>
        </header>
        <div>
          <article class="comm-course-list">
            <ul class="of" id="bna">
              <li v-for="video in videoList" :key="video.id">
                <div class="cc-l-wrap">
                  <section class="course-img">
                    <img
                      :src="video.cover"
                      class="img-responsive"
                      :alt="video.title"
                    >
                    <div class="cc-mask">
                      <a :href="'/play/'+video.id" title="观看视频" class="comm-btn c-btn-1">观看视频</a>
                    </div>
                  </section>
                  <h3 class="hLh30 txtOf mt10">
                    <a href="#" :title="video.title" class="course-title fsize18 c-333">{{video.title}}</a>
                  </h3>
                  <section class="mt10 hLh20 of">
                      <span class="fr jgTag bg-green" v-if="Number(video.price) === 0">
                        <i class="c-fff fsize12 f-fA">{{video.price}}</i>
                      </span>
                    <span class="fl jgAttr c-ccc f-fA">
                        <i class="c-999 f-fA" style="color: #00abf2"><i class="el-icon-view"></i> {{video.viewCount}}评论</i>
                      </span>
                  </section>
                </div>
              </li>
            </ul>
            <div class="clear"></div>
          </article>
          <section class="tac pt20">
            <a href="/dashboard/list" title="全部视频" class="comm-btn c-btn-2">全部视频</a>
          </section>
        </div>
      </section>
    </div>
  </div>

</template>

<script>
  import dashboard from "../../api/dashboard";
export default {
    name: "list",
    data(){
      return{
         videoList:[],
          images:[
            'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2304273337,2667639627&fm=26&gp=0.jpg',
            'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3496870847,4674976&fm=26&gp=0.jpg',
            'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2874487848,1107848552&fm=26&gp=0.jpg'
          ]
      }
    },
    created(){
         this.getRecommend();
    },
    methods:{
      getRecommend(){
         dashboard.getRecommend().then(res=>{
           this.videoList=res.data.data.list
         })
      }

    }
  }
</script>

<style>
  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 150px;
    margin: 0;
  }

  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }

  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
</style>
